package cn.pfund.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

 /**
 * 企业信息类别
 * @author zhaominglei qq:351024274，专注于网站、app和游戏开发。
 * @date 2017年1月20日
 */
@Entity
@Table(name="pfund_companyinfo_type")
public class CompanyinfoType extends OrderEntity implements Serializable {
	private static final long serialVersionUID = 1008549124984008110L;
	public static final Integer COMPANYINFOTYPE_ABOUT_BELONGTO = 1;
	public static final Integer COMPANYINFOTYPE_KEFU_BELONGTO = 2;
	public static final Integer COMPANYINFOTYPE_XSSL_BELONGTO = 3;
	public static final Integer COMPANYINFOTYPE_AQBZ_BELONGTO = 4;
	public static final Integer COMPANYINFOTYPE_YWZZ_BELONGTO = 5;
	
	@SuppressWarnings("serial")
	public static final Map<Integer, String> map = new LinkedHashMap<Integer, String>(){
		{
			put(COMPANYINFOTYPE_ABOUT_BELONGTO, "关于我们");
			put(COMPANYINFOTYPE_KEFU_BELONGTO, "客服中心");
			put(COMPANYINFOTYPE_XSSL_BELONGTO, "新手上路");
			put(COMPANYINFOTYPE_AQBZ_BELONGTO, "安全保障");
			put(COMPANYINFOTYPE_YWZZ_BELONGTO, "业务资质");
		}
	};
	/** 类别 **/
	private String type;
	/** 网址 **/
	private String url;
	/** 归属 1关于我们 2客服中心  3新手上路 4安全保障 5业务资质**/
	private Integer belongto; 
    /** 企业信息  */
    private Set<Companyinfo> companyinfos = new HashSet<Companyinfo>();
    
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public Integer getBelongto() {
		return belongto;
	}
	public void setBelongto(Integer belongto) {
		this.belongto = belongto;
	}
	@OneToMany(mappedBy="companyinfoType", fetch=FetchType.LAZY, cascade = CascadeType.REMOVE)
	@OrderBy("createDate desc")
	public Set<Companyinfo> getCompanyinfos() {
		return companyinfos;
	}
	public void setCompanyinfos(Set<Companyinfo> companyinfos) {
		this.companyinfos = companyinfos;
	}
	@Transient
	public String getBelongtoLabel() {
		return map.get(getBelongto());
	}
}
